package com.atguigu.gulimall.thirdpart.controller;

import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.thirdpart.component.smsSendServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sms")
public class smsSendController {

    @Autowired
    smsSendServer smsSendServer;

    @GetMapping("/sendMessage")
    public void sendMessage(String phone,String code){
        try {
            SendSmsResponse sendSmsResponse = smsSendServer.sendMessage(phone, code);
            String resCode = sendSmsResponse.getBody().getCode();
            String message = sendSmsResponse.getBody().getMessage();
            System.out.println("短信发送响应的code:"+code);
            System.out.println("短信发送响应的message:"+message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
